package com.z.service.impl;

import com.z.entity.Users;
import com.z.entity.security.Admin;
import com.z.mapper.UsersMapper;
import com.z.result.ResultWrapper;
import com.z.service.UsersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zz
 * @since 2021-08-13
 */
@Service
public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements UsersService {
    @Autowired
    UsersMapper usersMapper;

    @Override
    public Admin getAdminByLoginAcct(String username) {
        return usersMapper.selectAdminByUserName(username);
    }

    @Override
    public ResultWrapper updateRoleOfUser(Integer id, String rid) {

        if (rid != null) {

            Integer intRid = Integer.valueOf(rid);
            usersMapper.insertOneRole(id, intRid);
            return ResultWrapper.getSuccessBuilder().build();

        } else {
            return ResultWrapper.getFailBuilder().msg("updateRoleOfUser===rid参数为空").build();
        }


    }

}
